<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>默认点标记</title>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        html, body, #container {
            height: 100%;
            width: 100%;
        }

        .amap-icon img,
        .amap-marker-content img {
            width: 25px;
            height: 34px;
        }

        .marker {
            position: absolute;
            top: -20px;
            right: -118px;
            color: #fff;
            padding: 4px 10px;
            box-shadow: 1px 1px 1px rgba(10, 10, 10, .2);
            white-space: nowrap;
            font-size: 12px;
            font-family: "";
            background-color: #25A5F7;
            border-radius: 3px;
        }

        .input-card {
            width: 18rem;
            z-index: 170;
        }

        .input-card .btn {
            margin-right: .8rem;
        }

        .input-card .btn:last-child {
            margin-right: 0;
        }
    </style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="//api.map.baidu.com/api?v=3.0&ak=L5vjiT9u0XLsvx2R5EzG53DTRG5SAWQA"></script>
<!--<script type="text/javascript"
        src="https://webapi.amap.com/maps?v=1.4.15&key=bG7iudLNGnNE2tSdOhAEtiL3Qu5dpIEF"></script>-->
<script type="text/javascript">
    var map = new BMap.Map("container");
    map.enableScrollWheelZoom(true);
    map.centerAndZoom("武汉",12);
    var company = [{
        id:"",
        address:"",
        latitude:"",
        longitude:""
    }];

    axios.post("/company/findAll.do").then((resp)=>{
        company = resp.data.data;
        console.log(company);
        if (resp.data.flag){
            for (var i = 0; i < company.length; i++) {
                var opts = {
                    offset: new BMap.Size(20,-20)
                }
                var point = new BMap.Point(company[i].longitude,company[i].latitude);
                map.centerAndZoom(point, 15);
                var label = new BMap.Label(company[i].address,opts);
                var marker = new BMap.Marker(point);

                marker.setLabel(label);
                map.addOverlay(marker);
            }
        }
    });
</script>
</body>
</html>